#pragma config(Sensor, in1,    Light,          sensorReflection)
#pragma config(Sensor, in2,    ,               sensorLineFollower)
#pragma config(Sensor, in3,    LeftLine,       sensorLineFollower)
#pragma config(Sensor, dgtl1,  Bumper,         sensorTouch)
#pragma config(Motor,  port2,           LeftMotor,     tmotorVex269, openLoop, reversed)
#pragma config(Motor,  port4,           RightMotor,    tmotorVex269, openLoop)
#pragma config(Motor,  port6,           LeftTop,       tmotorVex269, openLoop)
#pragma config(Motor,  port8,           ClawMotor,     tmotorVex269, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

int checkLight() {
  int lightsensed = 0;
  int lightvalue = SensorValue (Light);
  if (lightvalue <100) {
    lightsensed = 1;
  }
  return lightsensed;
}

bool checkBump(){
  return SensorValue (Bumper);
}

void moveRobot (int speed){
  motor[LeftMotor]=speed;
  motor[RightMotor]=speed;
}

void turnRobot (int leftspeed,int rightspeed){
  motor [LeftMotor]=leftspeed;
  motor [RightMotor]=rightspeed;
}
task main (){ motor[LeftMotor]=58;
  while (true){
    int lightsensed = checkLight();
    bool bumpsensed = checkBump ();
    if (lightsensed) {
      moveRobot (127);
      wait1Msec(3400);
      turnRobot (-127,127);
      wait1Msec(1250);
      moveRobot (127);
      wait1Msec(2000);
      turnRobot (-127,127);
      wait1Msec (1250);
      moveRobot (127);
      wait1Msec (3400);
      turnRobot (-127,127);
      wait1Msec (1250);
      moveRobot (127);
      wait1Msec (2000);
      moveRobot (0);
    }
  }
}
